//
//  ResidenceTableView.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/11.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "ResidenceTableView.h"
#import "HomeCell.h"

@implementation ResidenceTableView


- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
  self = [super initWithFrame:frame style:style];
  if (self) {
  }
  return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  
  if ([ToolsServer sharedInstance].isLoginApp == YES) {
    return self.data.count;
  } else {
    return 0;
  }
  
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  if ([ToolsServer sharedInstance].isLoginApp == YES) {
    return  (ScreenWidth - 40) * ITEMPRO + 10;
  } else {
    
  }
  return 0.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  if ([ToolsServer sharedInstance].isLoginApp == YES) {
    ///!
    static NSString *newIdentify = @"HomeCell";
    HomeCell *cell = [tableView dequeueReusableCellWithIdentifier:newIdentify];
    if (!cell) {
      cell = [[HomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:newIdentify];
    }
    
    cell.model = self.data[indexPath.row];
    return cell;
    
  } else {
    return [super tableView:self cellForRowAtIndexPath:indexPath];
  }
  
}

@end
